package com.lovo.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lovo.bean.SysGoods;
import com.lovo.service.ISysGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * ??̨??????Ʒ? 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@RestController
@RequestMapping("hd/goods")
public class SysGoodsController {

    @Autowired
    ISysGoodsService goodsService;

    @GetMapping("findGoodsByItem")
    public IPage<SysGoods> findGoodsByItem(Integer PageNO,
                                           String goodsName,
                                           String goodsType) {

        return goodsService.findGoodsByItem(PageNO, goodsName, goodsType);
    }

    @PutMapping("/updateStatus/{goodsId}")
    public String updateStatusByGoodsId(@PathVariable("goodsId") Integer goodsId) {
        goodsService.updateStatusByGoodsId(goodsId);
        return "ok";
    }


    @GetMapping("findAllGoods")
    public IPage<SysGoods> findAllGoods(Integer PageNO, String goodsName, String goodsType) {
        IPage<SysGoods> page = goodsService.findAllGoods(PageNO,goodsName,goodsType);
        return page;
    }

    @GetMapping("findGoodsByStatus/{PageNO}")
    public IPage<SysGoods> findGoodsByStatus(@PathVariable Integer PageNO) {
        IPage<SysGoods> page = goodsService.findGoodsByStatus(PageNO);
        return page;
    }

//    @PutMapping("sellGoods/{goodsId}/{num}")
//    public void sellGoods(@PathVariable("goodsId") Integer goodsId,
//                          @PathVariable("num") Integer num) {
//        goodsService.sellGoods(goodsId, num);
//    }
//
//    /**
//     * 添加库存商品
//     * @param goods 商品对象
//     */
//    @GetMapping("sendProduct")
//    public void sendProduct(SysGoods goods) {
//        goodsService.sendProduct(goods);
//    };

}
